package com.dlc.shop.user.common.listener;

import com.dlc.shop.bean.event.OpenShopInitEvent;
import com.dlc.shop.user.common.service.UserRightsService;
import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
 * @author gaozijie
 * @date 2023-04-19
 */
@Component
@AllArgsConstructor
public class UserOpenShopInitListener {

    private final Logger logger = LoggerFactory.getLogger(UserOpenShopInitListener.class);

    private final UserRightsService userRightsService;

    /**
     * 初始化店铺会员系统权益
     * @param event 事件
     */
    @EventListener(OpenShopInitEvent.class)
    public void initShopSysRights(OpenShopInitEvent event) {
        Long shopId = event.getShopDetail().getShopId();
        logger.info("===== init the shop[{}] member system rights ...=====", shopId);
        userRightsService.initShopSysRights(shopId);
    }
}
